package cn.sofwin.project.src;

import cn.sofwin.project.src.utils.CardUtil;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static CardUtil user = new CardUtil();
    public static void main(String[] args) {
        String cardNumber = null;
        while (true) {
            System.out.println();
            System.out.println("*************欢迎使用嗖嗖移动业务大厅***************");
            System.out.println("1.用户登录\t2.用户注册\t3.使用嗖嗖\t4.话费充值\t5.资费说明\t6.退出系统");
            System.out.print("请选择：");
            switch (sc.nextInt()) {
                case 1:
                    System.out.print("请输入手机卡号：");
                    cardNumber = sc.next();
                    if(!user.isExistCard(cardNumber))
                        break;
                    System.out.print("请输入密码：");
                    user.card.get(cardNumber).cardNumber = cardNumber;
                    if (user.isExistCard(cardNumber, sc.next()))
                        secondMenu(cardNumber);
                    else
                        System.out.println("对不起，您输入的信息有误，无法登录！");
                    break;
                case 2:
                    user.initScene();
                    break;
                case 3:
                    System.out.print("输入卡号：");
                    user.useSoso(sc.next());
                    break;
                case 4:
                    System.out.print("请输入充值卡号：");
                    cardNumber = sc.next();
                    System.out.print("充值金额：");
                    user.chargeMoney(cardNumber, sc.nextDouble());
                    break;
                case 5:
                    user.showDescription();
                    break;
                case 6:
                    return;
                default:
                    System.out.println("输入不正确");
            }
        }
    }
    public static void secondMenu(String cardNumber){
        int in;
        do {
            System.out.println();
            System.out.println("*****嗖嗖移动用户菜单*****");
            System.out.println("1.本月账单查询\n2.套餐余量查询\n3.打印消费详单\n4.套餐变更\n5.办理退网");
            System.out.print("请选择(输入1~5选择功能，其他键返回上一级)：");
            in = sc.nextInt();
            switch (in) {
                case 1:
                    user.showAmountDetail(cardNumber);
                    break;
                case 2:
                    user.showRemainDetail(cardNumber);
                    break;
                case 3:
                    user.printConsumInfo(cardNumber);
                    break;
                case 4:
                    user.changingPack(cardNumber);
                    break;
                case 5:
                    System.exit(0);
                default:
                    return;
            }
        }while (true);
    }
}
